#pragma once

#include <QThread>
#include <QAudioFormat>
#include <QAudioInput>
#include <QDebug>
#include <QString>
#include <iostream>

class AudioRecordThread : protected QThread
{
private:
	QAudioFormat fmt;
	QAudioInput* input;
	QIODevice* io;
	void Init();


	FILE* fp = NULL;

public:
	int sampleRate = 44100;//采样率
	int channelCount = 2;//声道数
	int sampleSize = 16;//采样格式（S16,16byte）
	bool isRecord = true;//是否录制
	QString outFilePath="out.pcm";
	void Start();
	void Stop();
	static AudioRecordThread* Get()
	{
		static AudioRecordThread art;
		return &art;
	}
	~AudioRecordThread();
protected:
	AudioRecordThread();
	void run() override;
};
